Individual contributions to each section of this document are as follows:

Elise Drivon:

I, Elise Drivon, had primary responsiblity for sections 1.2, 2.2, and 3.2.

Daragh Hollman:

I, Daragh Hollman, had primary responsibility for sections 1.1, 2.1, and 3.1.

Catherine Kwagala:

Lauren Nelson:

I, Lauren Nelson, had primary responsibility for sections 3.4 and 4.

# Import packages here
library(ggplot2)
library(viridis)
library(tidyverse)
library(RColorBrewer)
library(readr)
library(ggthemes)
library(tidyr)
library(GGally)
library(plotly)
library(dplyr)
library(sf) # Required udunits, and gdal system dependancies on Linux as packages are installed from source rather than binary. https://r-spatial.github.io/sf/

1. Introduction

In this section, we describe the datasets used throughout this report and outline our science question: “How have Ireland’s traffic collisions changed in recent years?”

1.1 Datasets

The dataset used in this work was ROA27: Traffic Collisions and Casualties by the Central Statistics Office (CSO). This dataset contained collision and casualty data for all 26 counties in Ireland between the years 2013 and 2023. It recorded 6 statistics:

  • Fatal Collisions
  • Injury Collisions
  • All Fatal and Injury Collisions
  • Killed Casualties
  • Injured Casualties
  • All Killed and Injured Casualties

Each of these statistics was provided for each county (and also given as a total) for each year in the dataset.

load("traffic.Rdata")

Additionally, we also used a dataset containing the geometrical information (in latitude and longitude) for each Local Electoral Authority (LEA) in Ireland (see brendanjodowd/maps). Included in this dataset was the area of each LEA, and its population as of the 2016 census.

# I wrote this section prior to the class on maps, following this guide:
# https://brendanjodowd.github.io/map_guide/
# The below .geojson file is from this Github repository: https://github.com/brendanjodowd/maps
# The README outlines how these this file was created.
lea_166 <- st_read("https://raw.githubusercontent.com/brendanjodowd/maps/main/lea_166.geojson")

1.2 Research Question

In this research, we will observe the evolution of traffic collision data in Ireland from 2013 to 2023. We will see the variations across the different counties and identify potential trends over time. Indeed, we expect to observe a reduction of traffic collisions in 2020 and 2021, when most activities were restricted in Ireland due to the COVID-19 pandemic.

2. Data Adjustments

2.1 Combining the CSO dataset with spatial data for each county

To give a visual overview of these collisions data across the counties of Ireland, we chose to create a heatmap of collisions for each county, and display these data on a map of Ireland. We used the LEA dataset described in Section 1.1 and grouped each LEA by county. We determined county-wide metrics for population and area as the sum of those metrics within each constituent LEA.

counties <- lea_166 |>
  group_by(COUNTY) |>
  summarise(geometry = st_union(geometry), POP=sum(Pop2016), AREA=sum(AREA))

We joined the CSO dataset and the counties dataset with the following method. For this display, we only showed total collisions, and hence we first filtered the CSO dataset to only include the All Fatal and Injury Collisions statistic. Further, we removed the All Counties row as it was not needed for this display. This left a dataset containing 26 rows (one for each county) and 11 columns (one for each year). We used pivot_longer() to create a row for each pair of county and year, recording the total collisions. Additionally, we determined the mean for each county across all years. The collisions dataset and counties dataset were then combined (merging on the County rows - COUNTY in the counties dataset). The counties dataset contained information for Northern Ireland, however, as the collisions dataset does not report on counties in Northern Ireland, this created ‘na’ values in our resultant dataset, which were removed.

county_collisions_per_year <- traffic |>
  filter(Statistic == "All Fatal and Injury Collisions") |>
  filter(County != "All Counties") |>
  pivot_longer(
    cols = `2013`:`2023`,
    names_to = "Year",
    values_to = "Total Collisions"
  ) |>
  select(`County`, `Year`, `Total Collisions`)

# We also want to show the mean over all years
county_means <- county_collisions_per_year |>
  group_by(County) |>
  summarise(
    Year = "Mean",
    `Total Collisions` = mean(`Total Collisions`)
  )

# Add the mean rows to the dataset
county_collisions_per_year <- bind_rows(county_collisions_per_year, county_means)

county_collisions_per_year <- counties |>
  left_join(county_collisions_per_year, by = c("COUNTY" = "County"))

# There is no traffic data for Northern Ireland, but there is collisions data.
# This gives us undefined entries which we must remove.
county_collisions_per_year <- county_collisions_per_year |>
  filter(!is.na(Year))

Lastly, these data contain large outliers associated with the large population differences across the counties in Ireland (e.g. Dublin: ~1.35M, Cork: ~540k, Leitrim: ~30k - 1st, 2nd, and 32nd most populous counties in Ireland in 2016). We note that in this display, were were only interested in spatial changes in time, and hence we assumed population changes were not significant. This assumption is less reliable for counties in Leinster, which showed the most rapid increases in population between 2011-2016 (see Census 2016 Summary Results - Part 1, Chapter 1, Page 11).

# Convert from collisions to collisons per capita
county_collisions_per_year <- county_collisions_per_year |>
  mutate(`Collisions per Capita` = `Total Collisions` / POP)

2.2 Grouping counties into provinces

We grouped the counties available in the dataset into their provinces. We then computed the sum of collisions for each of the provinces.

traffic |> 
  filter(!County == "All Counties") |> 
  filter(Statistic == "All Fatal and Injury Collisions") -> collisions_data

collisions_data |> mutate(Province = case_when(
   County %in% c("Galway", "Leitrim", "Mayo", "Roscommon", "Sligo") ~ "Connacht",
   County %in% c("Carlow","Dublin", "Kildare", "Kilkenny", "Laois", "Longford", "Louth", "Meath", "Offaly", "Westmeath", "Wexford", "Wicklow") ~ "Leinster" ,
   County %in% c("Clare", "Cork", "Kerry", "Limerick", "Tipperary", "Waterford"
) ~ "Munster",
   County %in% c("Cavan", "Donegal", "Monaghan") ~ "Ulster" 
)) -> provinces

#This code computes the sum of collisions in each province per year
provinces_per_year <- provinces |>
  group_by(Province) |>
  summarise(across(`2013`:`2023`, ~ sum(.x, na.rm = TRUE)))

3. Analysis

3.1 Total Collisions per Capita per County

ggplot(county_collisions_per_year) +
  geom_sf(aes(fill = `Collisions per Capita`)) +
  scale_fill_viridis(name="Collisions per Capita", option="plasma") +
  facet_wrap(~Year) +
  # Make the colourbar span the height of the figure
  # https://stackoverflow.com/questions/79318640/how-can-i-make-the-legend-color-bar-the-same-height-as-my-facet-wrapped-plot-pan
  guides(
    fill = guide_colorbar(
      direction = "vertical",
      barheight = unit(0.75, "npc"),
      barwidth  = unit(0.03, "npc")
    )
  ) +
  theme_bw(
    # Increase font size
    base_size = 20,
  ) +
  theme(
    # Remove the axis labels, we don't really need them, and the longitude ticks
    # wwere overlapping.
    axis.text = element_blank(),
    axis.ticks = element_blank(),
    legend.margin = margin(0)
  )
**Figure 1**: Total traffic collisions per capita by county between 2013 and 2023. The collisions data were normalised by constant population from the 2016 census.

Figure 1: Total traffic collisions per capita by county between 2013 and 2023. The collisions data were normalised by constant population from the 2016 census.

Figure 1 shows the distribution of collisions by county for each year between 2013 and 2023. The mean across all years was additionally displayed. These distributions were normalised by population to compare collisions per capita between counties, and its change in time. We highlight the following qualitative findings from these distributions:

  • The mean collisions per capita show relatively equal collisions with small variations between counties. Longford has the largest number of collisions for its population on average. Also elevated (in no particular order) were Kerry, Limerick, Waterford, Cavan, Louth. Clare showed the lowest average collisions per capita during the time period.

  • The COVID-19 pandemic is evident in the data. The number of collisions per captial for all counties is much lower in 2020 and 2021, which reflects the multiple state-wide stay-at-home orders in place during during these years.

  • We observe a gradual increase in collisions in the north of the country (clustered around Leitrim). This increase peaks in 2016, where Leitrim shows the largest number of collisions per capita for all years in this dataset, after which, we find a general decrease in this area.

3.2 Fatal collisions across all counties

ggparcoord(provinces_per_year,
    columns = 2:12, groupColumn = 1, scale="globalminmax"
    ) +  labs(x = "Year", y = "Total Collisions", title = "Evolution of all collisions")-> plot_evolution

ggplotly(plot_evolution)

Figure 2: Fatal collisions in Ireland from 2013 to 2023

We can see clearly that the data decreases significantly in 2020 and 2021 and increases again after 2022. For each province, the number of collisions in 2023 returns to approximately the same level as in 2013. Therefore, we can see that the pandemic had an effect on traffic and collisions. The number of collisions dropped during the two years of restrictions due to the COVID-19. The province of Leinster shows more fluctuations and a general increase in collisions from 2013 to 2023 probably due to the increase of population during those 10 years.

3.4 Fatal and injury collisions across all counties

Collisionslonger <- traffic |>
  filter(Statistic == "All Fatal and Injury Collisions", County == "All Counties") |>
pivot_longer(cols = `2013`:`2023`, names_to = "year" , values_to = "value" )


ggplot(data = Collisionslonger,
       aes(x = year, y = value, fill = year)) +
  geom_col() +
  theme(axis.text.x = element_text(angle = 45, hjust=1)) +
  geom_col(aes(fill = year == 2020), show.legend = FALSE) +
   scale_fill_manual(values = c("FALSE" = "lightblue", "TRUE" = "purple3")) +
  xlab("Year") +
  ylab("Number of fatal and injury collisions") +
  theme(legend.position = "none")

ggplot(data = Collisionslonger,
       aes(x = value, y = reorder(year, value, sum, na.rm=T), fill = value)) +
  geom_col() +
  theme(axis.text.x = element_text(angle = 45, hjust=1)) +
  scale_fill_distiller(palette = "YlGn", direction = 1) +
  xlab("Number of fatal and injury collisions") +
  ylab("Year") +
  theme(legend.position = "none")
**Figure 4:** Number of fatal and injury collisions happening per year in all counties between 2013 and 2023.**Figure 4:** Number of fatal and injury collisions happening per year in all counties between 2013 and 2023.

Figure 4: Number of fatal and injury collisions happening per year in all counties between 2013 and 2023.

Figure 4 shows the number of collisions by year between 2013 and 2023 in all counties in the form of two column charts. These charts are to highlight the following qualitative findings: - we observe a gradual increase in collisions across all counties. this drops in 2020, as highlighted by the charts, and peaks in 2017. - The drop in 2020 is evident as Covid-19, where the pandemic was causing lockdowns state-wide. -This drop in collisions highlights how with less population density on the roads and streets, there are less incidents and safer spaces.

4. Summary and Conclusions

From the plots created, we are able to observe from the data that there appears to be a steady increase in the number of collisions and casualties across Ireland. There were relatively equal collisions with only small variation between the counties. There is a sudden drop in the years 2019 and 2020, which can be assumed to be because of the Covid-19 pandemic. The years following 2020 show an uptick in the number of collisions, showing a trend in the increase of collisions as time goes by.

From the produced plots, we can come to the conclusion that due to worsening traffic conditions and an increasing population of drivers and overall population density, there is a steady increase in the number of car incidents each year. There are outliers in the years 2019 and 2020, but those can be concluded to be because of the Covid 19 pandemic, in which there were several lockdowns that decreased the number of cars on the roads and number of people in the streets in general, dropping the numbers of both collisions and casualties. It can thus be concluded that as long as there continues to be an increase in population densities and cars on the road, there will be rising incident numbers caused by genuine accidents, the popularity of phones and general recklessness.